package com.ctshk.common.enums;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 系统业务类型枚举
 * </p>
 *
 * @author 胡广
 * @since 2021/2/26
 */
public enum SystemBusinessType {
    OUTBOUND_TRAVEL(1, "出境遊"),
    INBOUND_TRAVEL(2, "入境遊"),
    OUTBOUND_CUSTOMIZATION(3, "出境定制"),
    INBOUND_CUSTOMIZATION(4, "入境定制"),
    CONFERENCE_AWARDS(5, "會議會獎"),
    FIXED_PACKAGE_TICKET(6, "固定套票"),
    DYNAMIC_PACKAGE_TICKET(7, "動態套票"),
    HOTEL(8, "酒店"),
    AIR_TICKET(9, "機票"),
    TRAIN_TICKET(10, "火車票"),
    SHIP_TICKET(11, "船票"),
    BUS_TICKET(12, "巴士票"),
    AIR_EXPRESS(13, "機場快線"),
    ATTRACTION_TICKET(14, "景點門票"),
    LOCAL_FUN(15, "當地玩樂"),
    VISA(16, "簽證"),
    CERTIFICATE_HANDLE(17, "證件辦理"),
    COMMODITY(18, "商品"),
    FINANCE(19, "财务中心"),
    IOTC(20, "運營中心"),
    BOOKING(21, "供應商預訂"),
    RESOURCES(22, "系統資源"),
    INSURANCE(24, "保险"),
    AIR_SHOW(25, "珠海航展"),
    ;

    private int code;
    private String value;

    SystemBusinessType(int code, String value) {
        this.code = code;
        this.value = value;
    }

    public int getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public static String parseValue(int code) {
        for (SystemBusinessType type : SystemBusinessType.values()) {
            if (type.code == code) {
                return type.getValue();
            }
        }
        return null;
    }

    public static String parseName(int code) {
        for (SystemBusinessType type : SystemBusinessType.values()) {
            if (type.code == code) {
                return type.name();
            }
        }
        return null;
    }

    public static SystemBusinessType parseCode(int code) {
        for (SystemBusinessType type : SystemBusinessType.values()) {
            if (Objects.equals(type.code, code)) {
                return type;
            }
        }
        return null;
    }

    /**
     * 获取团枚举列表
     *
     * @return
     */
    public static List<Integer> getGroupList() {
        return Arrays.asList(SystemBusinessType.OUTBOUND_TRAVEL.getCode(), SystemBusinessType.INBOUND_TRAVEL.getCode(),
                SystemBusinessType.OUTBOUND_CUSTOMIZATION.getCode(), SystemBusinessType.INBOUND_CUSTOMIZATION.getCode(),
                SystemBusinessType.CONFERENCE_AWARDS.getCode());
    }

    /**
     * 获取单项枚举列表(酒店,機票,火車票,船票,巴士票,機場快線,景點門票,當地玩樂,簽證,證件辦理,商品)
     *
     * @return
     */
    public static List<Integer> getSingleList() {
        return Arrays.asList(SystemBusinessType.HOTEL.getCode(), SystemBusinessType.AIR_TICKET.getCode(),
                SystemBusinessType.TRAIN_TICKET.getCode(), SystemBusinessType.SHIP_TICKET.getCode(),
                SystemBusinessType.BUS_TICKET.getCode(), SystemBusinessType.AIR_EXPRESS.getCode(),
                SystemBusinessType.ATTRACTION_TICKET.getCode(), SystemBusinessType.LOCAL_FUN.getCode(),
                SystemBusinessType.VISA.getCode(), SystemBusinessType.CERTIFICATE_HANDLE.getCode(),
                SystemBusinessType.COMMODITY.getCode());
    }

}
